(function(vc){
    vc.extends({
        propTypes: {
           emitChooseShopVipLevel:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseShopVipLevelInfo:{
                shopVipLevels:[],
                _currentShopVipLevelName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseShopVipLevel','openChooseShopVipLevelModel',function(_param){
                $('#chooseShopVipLevelModel').modal('show');
                $that._refreshChooseShopVipLevelInfo();
                $that._loadAllShopVipLevelInfo(1,10,'');
            });
        },
        methods:{
            _loadAllShopVipLevelInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('shopVipLevel.listShopVipLevels',
                             param,
                             function(json){
                                var _shopVipLevelInfo = JSON.parse(json);
                                $that.chooseShopVipLevelInfo.shopVipLevels = _shopVipLevelInfo.shopVipLevels;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseShopVipLevel:function(_shopVipLevel){
                if(_shopVipLevel.hasOwnProperty('name')){
                     _shopVipLevel.shopVipLevelName = _shopVipLevel.name;
                }
                vc.emit($props.emitChooseShopVipLevel,'chooseShopVipLevel',_shopVipLevel);
                vc.emit($props.emitLoadData,'listShopVipLevelData',{
                    shopVipLevelId:_shopVipLevel.shopVipLevelId
                });
                $('#chooseShopVipLevelModel').modal('hide');
            },
            queryShopVipLevels:function(){
                $that._loadAllShopVipLevelInfo(1,10,$that.chooseShopVipLevelInfo._currentShopVipLevelName);
            },
            _refreshChooseShopVipLevelInfo:function(){
                $that.chooseShopVipLevelInfo._currentShopVipLevelName = "";
            }
        }

    });
})(window.vc);
